﻿using System;
using System.Collections.Generic;

namespace ARchGL.Platform.WindowsService.Core
{
    /// <summary>
    /// 专业信息 ViewModel
    /// </summary>
    public class UserMajorsReportDto
    {
        /// <summary>
        /// 总数
        /// </summary>
        public int TotalCount { get; set; }

        /// <summary>
        /// 专业信息
        /// </summary>
        public List<MajorsReportDto> MajorCount { get; set; }

        ///// <summary>
        ///// 获取数据一半的长度
        ///// </summary>
        ///// <returns></returns>
        //public int GetHalfLength
        //{
        //    get
        //    {
        //        decimal a = MajorCount.Count / 2;
        //        return (int)Math.Ceiling(a);
        //    }
        //}

        /// <summary>
        /// 获取连续两位中最长的长度
        /// </summary>
        /// <returns></returns>
        public int GetGroupLength(int index)
        {
            var length = MajorCount[index].Name.Length;
            if (index % 2 == 0)//奇数和下一个比较
            {
                var nextIndex = index + 1;
                if (nextIndex < MajorCount.Count)
                {
                    var nextLength = MajorCount[nextIndex].Name.Length;
                    return length > nextLength ? length : nextLength;
                }
            }
            else//偶数和上一个比较
            {
                var prevIndex = index - 1;
                if (index > 0)
                {
                    var nextLength = MajorCount[prevIndex].Name.Length;
                    return length > nextLength ? length : nextLength;
                }
            }
            return length;
        }
    }

    /// <summary>
    /// 专业信息 ViewModel
    /// </summary>
    public class MajorsReportDto
    {
        /// <summary>
        /// 专业名称
        /// </summary>
        public string Name { get; set; }

        /// <summary>
        /// 人数信息
        /// </summary>
        public string Value { get; set; }
    }

    //{"result":{"title":"铁投\n华汇","content":"{\"TotalCount\":1,\"MajorCount\":[{\"Color\":null,\"Name\":\"其他-1\",\"Value\":1}]}"},"success":true}
}
